package com.start.manager.util;

import com.start.manager.domain.enums.ResultEnum;
import lombok.Data;

/**
 * 返回的类
 *
 * @author jian.li
 * @date 2019年 12月13日 14:20:36
 */
@Data
public class ResponseResult {

    private boolean result;

    private String code;

    private String message;

    private Object data;

    private ResponseResult() {
    }

    public static ResponseResult of(boolean result,String code,String message,Object data){
        ResponseResult responseResult = new ResponseResult();
        responseResult.setResult(result);
        responseResult.setCode(code);
        responseResult.setMessage(message);
        responseResult.setData(data);
        return responseResult;
    }

    public static ResponseResult success(String message,Object data){
        return of(true, ResultEnum.SUCCESS.getCode(),message,data);
    }
    public static ResponseResult success(String message){
        return of(true, ResultEnum.SUCCESS.getCode(),message,null);
    }
    public static ResponseResult success(){
        return of(true, ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMessage(),null);
    }
    public static ResponseResult success(Object data){
        return of(true, ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMessage(),data);
    }
    public static ResponseResult success(ResultEnum resultEnum){
        return of(true,resultEnum.getCode(),resultEnum.getMessage(),null);
    }
    public static ResponseResult success(ResultEnum resultEnum,Object data){
        return of(true,resultEnum.getCode(),resultEnum.getMessage(),data);
    }
    public static ResponseResult error(){
        return of(false,ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMessage(),null);
    }
    public static ResponseResult error(String message){
        return of(false,ResultEnum.ERROR.getCode(),message,null);
    }
    public static ResponseResult error(ResultEnum resultEnum){
        return of(false,resultEnum.getCode(),resultEnum.getMessage(),null);
    }
    public static ResponseResult error(ResultEnum resultEnum,Object data){
        return of(false,resultEnum.getCode(),resultEnum.getMessage(),data);
    }

}
